package com.dongliusuo.orangeforms.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.dongliusuo.orangeforms.application.common.constant.BankCardType;
import com.dongliusuo.orangeforms.common.core.util.MyCommonUtil;
import com.dongliusuo.orangeforms.common.core.annotation.*;
import com.dongliusuo.orangeforms.common.core.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 客户银行卡数据实体对象。
 *
 * @author DongLiusuo
 * @date 2025-01-08
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "customer_account")
public class CustomerAccount extends BaseModel {

    /**
     * 编号。
     */
    @TableId(value = "account_id")
    private Long accountId;

    /**
     * 客户编号。
     */
    @TableField(value = "customer_id")
    private Long customerId;

    /**
     * 账户类型：借记卡、贷记卡。
     */
    @TableField(value = "account_type")
    private String accountType;

    /**
     * 账户号。
     */
    @TableField(value = "account_no")
    private String accountNo;

    /**
     * 所属银行。
     */
    @TableField(value = "belong_bank")
    private String belongBank;

    /**
     * 开户行。
     */
    @TableField(value = "open_account_back")
    private String openAccountBack;

    /**
     * 开户姓名。
     */
    @TableField(value = "open_account_name")
    private String openAccountName;

    /**
     * 开户手机号。
     */
    @TableField(value = "open_account_phone")
    private String openAccountPhone;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * account_no / open_account_name / open_account_phone LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    /**
     * accountId 字段的分组统计数据。
     */
    @TableField(exist = false)
    private Long countaAccount;

    @RelationConstDict(
            masterIdField = "accountType",
            constantDictClass = BankCardType.class)
    @TableField(exist = false)
    private Map<String, Object> accountTypeDictMap;
}
